package com.lvhx.springboot.springbatch.sharedata;

import com.lvhx.springboot.entity.User;
import com.lvhx.springboot.springbatch.readfile.People;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;

import java.util.Date;

/**
 * @auther 吕宏旭
 * @date 2019/9/5 15:40
 */
public class SetDataHolderTasklet implements Tasklet {

    private ImportMetadataHolder importMetadataHolder;

    public void setImportMetadataHolder(ImportMetadataHolder importMetadataHolder) {
        this.importMetadataHolder = importMetadataHolder;
    }

    @Override
    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
        User user = new User();
        user.setName("linux");
        user.setId(9L);
        user.setPassword("chain");
        user.setVersion(1L);
        importMetadataHolder.setUser(user);

        return RepeatStatus.FINISHED;
    }
}
